Skip to main content

Methods & Params


Methods

MethodsDescription
constructor(dom1,dom2,optionsObj,paramsObj)The method to create a SwapChatSdk instance accepts four parameters
exect()After creating a SwapChatSdk instance, call the exect method of the instance without passing any parameters

Parameters of constructor

ParameterDescriptionRequired
dom1This dom1 is the first parameter of constructor and must be a real dom element. It will act as a container for the button that triggers the chat windowyes
dom2This dom2 is the second parameter of constructor and must be a real dom element. It will act as a container for the chat windowyes
optionsThis options is the third parameter of constructor, which is an ordinary object. His width and height properties are number type and will control the width and height of the chat windowno
paramsThis params is the fourth parameter of the constructor, which is an ordinary object. including six properties,see the following table for specific usage detailsyes

Properties for the params parameter object

PropertiesTypeValueDefaultDescriptionRequired
platformstringtwitter,
discord,
opensea,
swapchat
swapchatThe platform
that will use
the sdk,
currently supports
twitter,
discord,
opensea,
swapchat
no
typestringsingle,
group,
thread
singleThe way of
using sdk,
currently supports
single,
group,
thread
no
room_payloadobject{}Parameters required to create room_idFor
different platforms
and different ways
of calling up
the chat window,
you need to
set the
corresponding parameters
If the value of the room_id attribute is set, room_payload does not need to be set. If room_id is not set, then room_payload is required
room_idstringGenerate
a room_id
according to
the official
api documentation
noneroom_id corresponding to the chat roomIf the value of the room_payload property is set, room_id does not need to be set. If room_payload is not set, then room_id is required
login_payloadobject{signature,
wallet_address,
login_random_secret,
user_avatar}
{}Login parameters
that need
to be set
If the value of the access_token attribute is set, the login_payload does not need to be set. If the access_token is not set, then the login_payload is required.
access_tokenstringGenerate a
access_token
according to
the official
api documentation
noneaccess_token corresponding to the login userIf the value of the login_payload property is set, access_token does not need to be set. If login_payload is not set, then access_token is required

Properties for the login_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
signaturestringGenerate a signature according to the official api documentationnoneThe signature of the currently logged in useryes
wallet_addressstringGenerate a wallet_address according to the official api documentationnoneThe address of the currently logged in useryes
login_random_secretstringGenerate a login_random_secret according to the official api documentationnonenoneyes
user_avatarstringnonenoneUser avatar addressno

When platform is opensea and the type is thread properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
opensea_coll_slugstringnonenonenoneyes
opensea_item_token_idstringnonenonenoneyes
opensea_item_contract_addressstringnonenonenoneyes
chain_namestringnonenoneUser avatar addressyes

When platform is swapchat and the type is thread properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
room_idstringnonenonenoneyes
msg_idstringnonenonenoneyes

When platform is swapchat and the type is single properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
user_idstringnonenoneuser_id of the user to chatyes
user_namestringnonenoneuser_name of the user to chatnone
user_avatarstringnonenoneuser_avatar of the user to chat|no

When platform is opensea and the type is single properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
user_namestringnonenoneuser_name of the user to chatyes
user_avatarstringnonenoneuser_avatar of the user to chat|no

When platform is discord and the type is single properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
user_idstringnonenoneuser_id of the user to chatyes
user_namestringnonenoneuser_name of the user to chatyes

When platform is twitter and the type is single properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
user_namestringnonenoneuser_name of the user to chatyes
user_avatarstringnonenoneuser_avatar of the user to chat|no

When platform is swapChat and the type is group properties for the room_payload parameter object

Not currently supported

When platform is opensea and the type is group properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
collection_namestringnonenonecollection_name of the ollection to chatyes

When platform is twitter and the type is group properties for the room_payload parameter object

PropertiesTypeValueDefaultDescriptionRequired
space_idstringnonenonespace_id of the space to chatyes
space_titlestringnonenonecollection_name of the ollection to chatno